package org.moonlight.jvm.instructions.control.ret;

import org.moonlight.jvm.instructions.base.NoOperandsInstruction;
import org.moonlight.jvm.rtda.exclusive.Frame;
import org.moonlight.jvm.rtda.exclusive.Thread;
import org.moonlight.jvm.rtda.share.Object;

/**
 * a_return指令: 用于返回 引用 的情况
 *
 * @author Moonlight
 * @createTime 2023/9/12 14:07
 **/
public class AReturn extends NoOperandsInstruction {

    @Override
    public void execute(Frame frame) {
        Thread thread = frame.getThread();
        Frame currentFrame = thread.popFrame();
        Frame invokeFrame = thread.topFrame();
        Object popRef = currentFrame.getOperandStack().popRef();
        invokeFrame.getOperandStack().pushRef(popRef);
    }

}
